/*     */ package com.wgcloud.util;
/*     */ 
/*     */ import java.sql.Timestamp;
/*     */ import java.text.ParseException;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.Calendar;
/*     */ import java.util.Date;
/*     */ import org.slf4j.Logger;
/*     */ import org.slf4j.LoggerFactory;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DateUtil
/*     */ {
/*  22 */   private static final Logger logger = LoggerFactory.getLogger(com.wgcloud.util.DateUtil.class);
/*     */ 
/*     */   
/*     */   private static final String DATE_PATTERN = "yyyy-MM-dd";
/*     */ 
/*     */   
/*     */   private static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
/*     */ 
/*     */   
/*     */   private static final String DATETIME_PATTERN_ZH = "yyyy年MM月dd日HH:mm:ss";
/*     */ 
/*     */   
/*     */   public static Timestamp getNowTime() {
/*  35 */     SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/*  36 */     Timestamp nowTime = Timestamp.valueOf(dateFormat.format(new Date()));
/*  37 */     return nowTime;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static String getCurrentDateTime() {
/*  48 */     return getCurrentDateTime("yyyy-MM-dd HH:mm:ss");
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static String getCurrentDate() {
/*  58 */     return getCurrentDateTime("yyyy-MM-dd");
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static String getCurrentDateTime(String pattern) {
/*  68 */     Calendar cal = Calendar.getInstance();
/*  69 */     SimpleDateFormat sdf = new SimpleDateFormat(pattern);
/*  70 */     return sdf.format(cal.getTime());
/*     */   }
/*     */   
/*     */   public static Date getDate(String dateStr) throws ParseException {
/*  74 */     return getDate(dateStr, "yyyy-MM-dd HH:mm:ss");
/*     */   }
/*     */ 
/*     */   
/*     */   public static Date getDate(String dateStr, String pattern) throws ParseException {
/*  79 */     Date date = null;
/*  80 */     SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
/*  81 */     date = dateFormat.parse(dateStr);
/*     */     
/*  83 */     return date;
/*     */   }
/*     */   
/*     */   public static String getDateString(Date date) {
/*  87 */     return getString(date, "yyyy-MM-dd");
/*     */   }
/*     */   
/*     */   public static String getDateTimeString(Date date) {
/*  91 */     return getString(date, "yyyy-MM-dd HH:mm:ss");
/*     */   }
/*     */   
/*     */   public static String getDateTimeZhString(Date date) {
/*  95 */     return getString(date, "yyyy年MM月dd日HH:mm:ss");
/*     */   }
/*     */   
/*     */   public static String getString(Date date, String pattern) {
/*  99 */     SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
/* 100 */     return dateFormat.format(date);
/*     */   }
/*     */   
/*     */   public static int getHour(Date date) {
/* 104 */     Calendar calendar = Calendar.getInstance();
/* 105 */     calendar.setTime(date);
/* 106 */     int hour = calendar.get(11);
/* 107 */     return hour;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static boolean isClearTime() {
/* 116 */     Calendar calendar = Calendar.getInstance();
/* 117 */     calendar.setTime(new Date());
/* 118 */     int hour = calendar.get(11);
/* 119 */     int mins = calendar.get(12);
/* 120 */     if (8 == hour && mins >= 10 && mins <= 25) {
/* 121 */       return true;
/*     */     }
/* 123 */     return false;
/*     */   }
/*     */   
/*     */   public static long secsOf2Day(String day1, String day2) {
/*     */     try {
/* 128 */       Date date1 = getDate(day1);
/* 129 */       Date date2 = getDate(day2);
/* 130 */       long secs = Math.abs(date1.getTime() - date2.getTime()) / 1000L;
/* 131 */       return secs;
/* 132 */     } catch (Exception e) {
/* 133 */       return -1L;
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   public static String getDateBefore(String datetimes, int day) {
/* 139 */     Calendar now = Calendar.getInstance();
/*     */     try {
/* 141 */       now.setTime(getDate(datetimes));
/* 142 */     } catch (ParseException e) {
/* 143 */       logger.error("时间格式 [ " + datetimes + " ]  无法被解析：" + e.toString());
/* 144 */       return null;
/*     */     } 
/* 146 */     now.set(5, now.get(5) - day);
/* 147 */     return getString(now.getTime(), "yyyy-MM-dd HH:mm:ss");
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static String secondToDate(Long second, String patten) {
/* 158 */     if (second == null) {
/* 159 */       return "";
/*     */     }
/* 161 */     Calendar calendar = Calendar.getInstance();
/* 162 */     calendar.setTimeInMillis(second.longValue() * 1000L);
/* 163 */     Date date = calendar.getTime();
/* 164 */     SimpleDateFormat format = new SimpleDateFormat(patten);
/* 165 */     String dateString = format.format(date);
/* 166 */     return dateString;
/*     */   }
/*     */ }


/* Location:              /Users/zhangyongxin/soft-install/wgcloud/wgcloud-v3.3.5/server/bank/wgcloud-server-release.jar!/BOOT-INF/classes/com/wgcloud/util/DateUtil.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */